GBML manual / Rooms

room_top

The y coordinate of the current room’s top edge - the vertical partner of room_left.

Syntax

room_top() -> int

Returns

int

Description

Gives back the y position of the top edge of the room you are in. It is the up-and-down partner of room_left, and everything that page says about the origin applies here too.

Remember that y counts down: the higher something is on the screen, the smaller its y. So the top edge is a smaller number than the bottom edge, and room_top() + 8 is 8 pixels below the top edge, not above it.

Write room_top() + 8 rather than working the number out from room_height. It says "8 pixels down from the top", and it is right in every project. The room counts down from its top-left corner, so the top edge is y = 0 in a project that follows the current rule.

Example

y = room_top() + 8;

Puts this instance 8 pixels down from the top edge of the room.

On the GBA

Same short run-time call as room_left, using the room’s height. Remember y grows downward, so the top edge is the smaller number.

See also: room_bottomroom_leftroom_rightroom_height